package net.melon.cata.inst.struts2.web;

import javax.servlet.http.HttpServletRequest;

import net.esj.basic.core.view.tools.ActionContext;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class CatalogURIInterceptor extends AbstractInterceptor {

	private static final String CATALOG_PERFIX = "catalog_";
	
	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		String uri = ((HttpServletRequest)ActionContext.getRequest()).getRequestURI();
		String actionName = uri.substring(uri.lastIndexOf("/")+1, uri.lastIndexOf("."));
		if(!actionName.startsWith(CATALOG_PERFIX)){
			invocation.invoke();
		}
		
		return null;
	}

}
